package mr.ali.webvideo.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class CorsConfig implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")       // 匹配所有以 /api 开头的接口
                .allowedOrigins("http://localhost:5173","https://static-mp-50b490fb-0ecd-4ea3-af55-98b3e63378d6.next.bspapp.com","https://min.erkantv.cn") // 允许的前端域名
                .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
                .allowedHeaders("*")
                .allowCredentials(true);     // 是否允许携带 cookie
    }
}